import 'package:fate_blind_box/ui/user/institution/IntegralInstition.dart';
import 'package:fate_blind_box/ui/user/institution/companyPodfile.dart';
import 'package:fate_blind_box/ui/user/institution/institution.dart';
import 'package:fate_blind_box/ui/user/institution/memManager.dart';
import 'package:fate_blind_box/ui/user/institution/registerinstitution.dart';
import 'package:fate_blind_box/ui/user/matchMaker/maker_manager.dart';
import 'package:fate_blind_box/ui/user/profile.dart';
import 'package:fate_blind_box/utils/common_widget.dart';
import 'package:flutter/material.dart';
import '../../../theme/theme_color.dart';
import '../institution/recommendCode.dart';
import 'loveMaker.dart';
import 'otherMaker.dart';


class matchMakerUI extends StatelessWidget {
  final String title;
  const matchMakerUI(this.title,{Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return _matchMakerUIWidget(title);
  }
}

class _matchMakerUIWidget extends StatefulWidget {
  final String title;
  const _matchMakerUIWidget(this.title,{Key? key}) : super(key: key);

  @override
  State<_matchMakerUIWidget> createState() => _matchMakerUIWidgetState();
}

class _matchMakerUIWidgetState extends State<_matchMakerUIWidget> {

  final List _listData = [{'img':'images/aixinM.png','title':'爱心红娘',"sub":'拥有50名粉丝，实名认证后\n可申请，可获得推广奖励','button':'申请'},
                     {'img':'images/rexinM.png','title':'热心红娘',"sub":'实名认证后可申请，可获得\n推广奖励','button':'申请'},
                     {'img':'images/yinpaiM.png','title':'银牌红娘',"sub":'银牌红娘，可获得更多奖励','button':'申请'},
                     {'img':'images/jinpaiM.png','title':'金牌红娘',"sub":'金牌红娘，可获得更多奖励','button':'申请'},
                     {'img':'images/zhizunM.png','title':'至尊红娘',"sub":'至尊红娘，可获得更多奖励','button':'申请'},];

  final List _listDataBuss = [{'img':'images/aixinM.png','title':'普通红娘',"sub":'上传营业执照','button':'申请'},
    {'img':'images/rexinM.png','title':'热心红娘',"sub":'营业执照认证','button':'申请'},
    {'img':'images/yinpaiM.png','title':'银牌红娘',"sub":'银牌红娘，可获得更多奖励','button':'申请'},
    {'img':'images/jinpaiM.png','title':'金牌红娘',"sub":'金牌红娘，可获得更多奖励','button':'申请'},
    {'img':'images/zhizunM.png','title':'至尊红娘',"sub":'至尊红娘，可获得更多奖励','button':'申请'},];


  @override
  Widget build(BuildContext context) {

    return AppWidget.navTitleBar(
      bgColor: const Color(0xFFF9F9F9),
      title:widget.title,
      childWidget:ListView.builder(
        itemBuilder: (_, index) {
          return widget.title == '个人红娘' ? _buildItems(_listData?[index], index) : _buildItems(_listDataBuss?[index], index);
        },
        itemCount:_listData.length,
      ),
    );
  }

  @override
  void initState() {
    super.initState();

  }

  @override
  _buildItems(Map map, int index) {
    return GestureDetector(
      child:Container(

        height: 95,
        margin: const EdgeInsets.fromLTRB(15, 10, 15, 0),
        decoration: ShapeDecoration(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(5),
            ),
            color: Colors.white,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              margin: EdgeInsets.symmetric(horizontal: 10),
              child: Image.asset(
                map['img'],
                width: 49,
                height: 49,
                fit: BoxFit.cover,
              ),
            ),

            // const SizedBox(
            //   width: 5,
            // ),
            Expanded(
              child: Container(
                // padding: const EdgeInsets.symmetric(vertical: 10),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      map["title"] ?? "",
                      style: TextStyle(
                          color: ThemeColor.textColor,
                          fontSize: 16,),
                    ),
                    const SizedBox(height: 7,),
                    Text(
                      map["sub"] ?? "",
                      style: TextStyle(
                          color: ThemeColor.checkNormalColor,
                          fontSize: 11,),
                    ),

                  ],
                ),
              ),
            ),

            GestureDetector(
              onTap: () async{

                _onTap(index,map["title"] ?? '');


              },
              child: Container(
                height: 32,
                margin: const EdgeInsets.only(right: 8),
                decoration: ShapeDecoration(
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(20),
                    ),
                    color: ThemeColor.appColor,
                ),
                alignment: Alignment.center,
                padding: const EdgeInsets.symmetric(horizontal: 12),
                child: Text(map['button'], style: const TextStyle(color: Colors.white,fontSize: 14),),
              ),
            ),
          ],
        ),
      )
    );
  }


  _onTap(int index,String title){
    if(index == 0) {
      Navigator.of(context).push(MaterialPageRoute(builder: (builder) => loveMakerUIWidget(widget.title)));
      // Navigator.of(context).push(MaterialPageRoute(builder: (builder) => const institutionUi()));
      // Navigator.of(context).push(MaterialPageRoute(builder: (builder) => companyPofileUI()));
      // Navigator.of(context).push(MaterialPageRoute(builder: (builder) => const integranlInstitionUI()));
      // Navigator.of(context).push(MaterialPageRoute(builder: (builder) => const memManagerUi()));
      // Navigator.of(context).push(MaterialPageRoute(builder: (builder) => recommendCodeUI()));
      // Navigator.of(context).push(MaterialPageRoute(builder: (builder) => registerInstitionUI('fff')));
    } else  {
      Navigator.of(context).push(MaterialPageRoute(builder: (builder) => otherMakerUIWidget(title, widget.title)));
    }
  }
}

